/**
 * Copyright 2013 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.viettel.core.entities.cms;

import java.io.Serializable;
import java.sql.Clob;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import com.viettel.core.enumtype.ArticleStatus;

/**
 *  TABLE BAI VIET
 *  @author: ToanTM1
 *  @version: 2.1
 *  @since: 27-02-2014 - 11:41:32
 */
@Entity
@Table(name = "PUBLIC_ARTICLE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name = "SEQ_STORE", sequenceName = "PUBLIC_ARTICLE_SEQ", allocationSize = 1)
public class PublicArticle implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 6677948234626637159L;

	/**
	 * ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
	@Column(name = "ID")
	private Integer id;
	
	/**
	 * AVATAR FULL
	 */
	@Basic
	@Column(name = "AVATAR_URL", length = 512)
	private String avatarUrl;
	
	/**
	 * AVATAR DA DROP
	 */
	@Basic
	@Column(name = "AVATAR_THUMB", length = 512)
	private String avatarThumb;
	
	/**
	 * TEN BAI VIET
	 */
	@Basic
	@Column(name = "NAME", length = 200)
	private String name;
	
	/**
	 * TEN BAI VIET KHONG DAU
	 */
	@Basic
	@Column(name = "NAME_TEXT", length = 200)
	private String nameText;
	
	/**
	 * NOI DUNG BAI VIET DAY DU
	 */
	@Basic
	@Column(name = "CONTENT")
	private Clob content;
	
	/**
	 * NOI DUNG BAI VIET DAY DU
	 */
	@Basic
	@Column(name = "CONTENT_TEXT")
	private Clob contentText;
	
	/**
	 * NOI DUNG BAI VIET DAY DU
	 */
	@Basic
	@Column(name = "CONTENT_HTML")
	private Clob contentHtml;
	
	/**
	 * NOI DUNG NGAN
	 */
	@Basic
	@Column(name = "SHORT_CONTENT", length = 2000)
	private String shortContent;
	/**
	 * BAI VIET THUOC MEDIA GI?
	 */
	@ManyToOne(targetEntity = Media.class)
	@JoinColumn(name = "MEDIA_ID", referencedColumnName = "id")
	@ForeignKey(name = "ARTICLE_MEDIA_FK")
	private Media media;
	
	/**
	 * BAI VIET THUOC LOAI GI?
	 */
	@ManyToOne(targetEntity = GroupCategory.class)
	@JoinColumn(name = "GROUP_CATEGORY_ID", referencedColumnName = "id")
	@ForeignKey(name = "PUBLIC_ARTICLE_GROUP_FK")
	private GroupCategory groupCategory;
	
	/**
	 * BAI VIET THUOC CHUYEN MON GI?
	 */
	@ManyToOne(targetEntity = TechniqueCategory.class)
	@JoinColumn(name = "TECHNIQUE_CATEGORY_ID", referencedColumnName = "id")
	@ForeignKey(name = "PUBLIC_ARTICLE_TECHNIQUE_FK")
	private TechniqueCategory techniqueCategory;
	
	/**
	 * BAI VIET THUOC LOAI GI?
	 */
	@ManyToOne(targetEntity = ArticleCategory.class)
	@JoinColumn(name = "ARTICLE_CATEGORY_ID", referencedColumnName = "id")
	@ForeignKey(name = "PUBLIC_ARTICLE_ARTICLE_FK")
	private ArticleCategory articleCategory;
	
	/**
	 * CHUYEN GIA VIET BAI
	 */
	@ManyToOne(targetEntity = CmsUser.class)
	@JoinColumn(name = "CMS_USER_ID", referencedColumnName = "id")
	@ForeignKey(name = "PUBLIC_ARTICLE_CMS_USER_FK")
	private CmsUser cmsUser;
	
	/**
	 * TYPE
	 */
	@Basic
	@Column(name = "TYPE", columnDefinition = "NUMBER(1,0)")
	private Integer type;
	
	/**
	 * TRANG THAI BAI VIET
	 */
	@Basic
	@Column(name = "STATUS", columnDefinition = "NUMBER(1,0)", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.ArticleStatus"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="ARTICLE_STATUSX")
	private ArticleStatus status;
	
	/**
	 * THOI GIAN TAO
	 */
	@Basic
	@Column(name = "CREATED_TIME", columnDefinition = "timestamp(9) default systimestamp", insertable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdTime;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getAvatarUrl() {
		return avatarUrl;
	}

	public void setAvatarUrl(String avatarUrl) {
		this.avatarUrl = avatarUrl;
	}

	public String getAvatarThumb() {
		return avatarThumb;
	}

	public void setAvatarThumb(String avatarThumb) {
		this.avatarThumb = avatarThumb;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNameText() {
		return nameText;
	}

	public void setNameText(String nameText) {
		this.nameText = nameText;
	}

	public Clob getContent() {
		return content;
	}

	public void setContent(Clob content) {
		this.content = content;
	}

	public Clob getContentText() {
		return contentText;
	}

	public void setContentText(Clob contentText) {
		this.contentText = contentText;
	}

	public Clob getContentHtml() {
		return contentHtml;
	}

	public void setContentHtml(Clob contentHtml) {
		this.contentHtml = contentHtml;
	}
	
	public String getShortContent() {
		return shortContent;
	}

	public void setShortContent(String shortContent) {
		this.shortContent = shortContent;
	}

	public Media getMedia() {
		return media;
	}

	public void setMedia(Media media) {
		this.media = media;
	}

	public GroupCategory getGroupCategory() {
		return groupCategory;
	}

	public void setGroupCategory(GroupCategory groupCategory) {
		this.groupCategory = groupCategory;
	}

	public TechniqueCategory getTechniqueCategory() {
		return techniqueCategory;
	}

	public void setTechniqueCategory(TechniqueCategory techniqueCategory) {
		this.techniqueCategory = techniqueCategory;
	}

	public ArticleCategory getArticleCategory() {
		return articleCategory;
	}

	public void setArticleCategory(ArticleCategory articleCategory) {
		this.articleCategory = articleCategory;
	}

	public CmsUser getCmsUser() {
		return cmsUser;
	}

	public void setCmsUser(CmsUser cmsUser) {
		this.cmsUser = cmsUser;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public ArticleStatus getStatus() {
		return status;
	}

	public void setStatus(ArticleStatus status) {
		this.status = status;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	
}
